<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="">
    <meta http-equiv="x-dns-prefetch-control" content="on">

    <title>已就位第一步</title>
    <link href="../../css/css.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-v1.11.2.min.js"></script>
    <script src="../../js/driver.js"></script>
    <script src="../../js/common.js"></script>
</head>
<body>
<section class="itemgroup mt10 p15">
    <div class="oneitem_xl" id="startAddr">
        <i class="iconfont mr5 green icon28">&#xe70d;</i>
        共和新路3288弄3号
    </div>
    <div class="oneitem_xl">
        <label class="gray mr5">联系人:</label>
        <span id="consignName">方大同</span>
        <i class="iconfont rightsmallicon">&#xe6db;</i>
        <label class="right" id="consignMobile">13800138000</label>
    </div>
</section>
<section class="itemgroup mt10">
    <div class="order_title_xl">重要提示</div>
    <div class="textarea_xl">
        <p>1. 请与起始点联系人再次确认配送要求和送货地址;</p>
        <p>2.请不要退出程序，否则会影响本单奖励</p>
    </div>
</section>
<section class="bottomarea">
    <button type="button" class="btn bottomonebtn_xl" onclick="goonBid2()">我已就位</button>
</section>
<form id="dataForm">
    <input type="hidden" name="waybillId" id="waybillId">
    <input type="hidden" id="longitude" name="lon">
    <input type="hidden" id="latitude" name="lat">
</form>
<script type="text/javascript">
    $(function () {
        //token验证
        checkDriverToken();
    });

    $(document).ready(function () {
        var waybillId = GetArgsFromHref("waybillId");
        $("#waybillId").val(waybillId);
        var url = _global.serverHost + "/driver/goon_bid1.htm";
        var data = {waybillId: waybillId};
        _callAjaxRequest(url, data, startBidBack);

        var consignMobile = 0;

        function startBidBack(data) {
            $("#startAddr").html('<i class="iconfont mr5 green icon20">&#xe70d;</i>' + data.waybill.startAddr);
            $("#consignName").html(data.waybill.consignName);
            $("#consignMobile").html(data.waybill.consignMobile);
            consignMobile = data.waybill.consignMobile;
        }

        uploadLocation(waybillId);
    });

    function goonBid2() {
        var url = _global.serverHost + "/driver/check_goon_bid1.htm?driverUuid=" + getCookie("driverUuid");
        var data = $("#dataForm").serialize();
        _callAjaxRequest(url, data, goonBid1Back);
    }

    function goonBid1Back(data) {
        if (data.code == "1") {
            window.location.href = "../start_bid/goon_bid2.html?waybillId=" + data.waybillId;
        } else {
            alert(data.message);
        }
    }
    function uploadLocation(waybillId) {
        var loc = "31.26270474,121.4037323";
        if (typeof javaHandler != "undefined") {
            loc = javaHandler.getCurrentLocation();
        }
        var locs = loc.split(",");
        $("#longitude").val(locs[1]);
        $("#latitude").val(locs[0]);
        var json_data = {
            waybillIds: waybillId,
            lat: locs[0],
            lon: locs[1],
            comment: "定时定位"
        };
        if (_global.sendPost == "0") {
            //此处我只需要拿一次司机的经纬度，用于做是否到点的判断
//            _callAjaxRequest(_global.serverHost + '/driver/location.htm', json_data, function (data) {
//                console.log(JSON.stringify(data));
//            });
        } else {
            callHTTPRequestLogon(JSON.stringify(json_data));//app调用
        }
    }
</script>
</body>
</html>